<%@tag pageEncoding="UTF-8" import="java.util.Map, ajaxjs.data.Field "%> 
<%@taglib prefix="commonTag" 	tagdir="/WEB-INF/tags/common/html"%>
<%@taglib prefix="commonUI" 	tagdir="/WEB-INF/tags/common/UI"%>
<%@taglib prefix="prototypeUI"	tagdir="/WEB-INF/tags/common/Prototype"%>
<%@attribute name="valueObj" 		required="true"  type="ajaxjs.data.Entity" description="实例"%>
<%@attribute name="methodName"     	required="true" 				 description="实例方法名(getInfoById())"%>
<%@attribute name="headFrag"     	required="false" fragment="true" description="插入头部的公共内容"%>
<%@attribute name="extraField"    	required="false" fragment="true" description="扩展字段的 Markup（位于正文上方）"%>
<%@attribute name="extraField2" 	required="false" fragment="true" description="扩展字段的 Markup（位于正文下方）"%>
<%@attribute name="serviceObj" 		required="true"  type="ajaxjs.data.service.Service" description="业务层"%> 
<%@variable name-given="labels"%>
<!DOCTYPE html>
<html>
	<commonTag:head lessFile="/admin/asset/less/main.less">
		<jsp:invoke fragment="headFrag" />
	</commonTag:head>
    <body>
    	<prototypeUI:nav />
<%
	Map<String, String> labels = Field.initInfEdit(serviceObj, request);
	
	jspContext.setAttribute("labels", labels);
	// 判断是否创建或修改
	boolean isCreate = request.getParameter("id") == null;
	if(!isCreate){ // 修改的
		Field.getInfoByValueObj(valueObj, methodName, request);
	}
%>
	<form action="../../service/${metaInfo.ns_id}/<%=isCreate ? "" : request.getParameter("id")%>" 
	style="border-top:1px solid white;padding-top:10px;">
	<%
	// update 有 id
	if(!isCreate){
	%>
<%-- 		<input type="hidden" name="id" class="entryId" value="<%=request.getParameter("id")%>" /> --%>
	<%}%>
	 	<table align="center" class="layoutTable">
			<tr> 
				<td class="labelWidth">${labels.name}：</td>
				<td><input placeholder="请填写${labels.name}" name="name" value="${entityInstance_Map.name}" type="text" /></td>
				<td>
				<%if(labels.get("catalog") != null){
					out.println(labels.get("catalog") + "：");
				} %>
				<td> 
				<%if(labels.get("catalog") != null){ %>
					<select name="catalog" data-subObject="Catalog" data-value="${entityInstance_Map.catalog}">				
					</select>
				<%} %>
				</td>
			</tr>
			<tr> 
				<td>${labels.createDate}：</td>
				<td>
					<commonUI:calendar>
						<input placeholder="如不填则由系统自动提供"  name="createDate" type="text" value="${entityInstance_Map.createDate}" />
					</commonUI:calendar>
				</td>
				<td class="labelWidth">${labels.updateDate}：</td>
				<td>
					<commonUI:calendar>
						<input placeholder="如不填则由系统自动提供" name="updateDate" type="text" value="${entityInstance_Map.updateDate}" />
					</commonUI:calendar>
				</td>
			</tr>
			<jsp:invoke fragment="extraField" />
			<tr>
				<td>${labels.content}：</td>
				<td colspan="3">
					<%
						String basePath = request.getContextPath() +"/" + ((Map<String, String>)request.getAttribute("metaInfo")).get("ns_name");
					%>
					<commonUI:htmlEditor iframePath="../public/" basePath="<%=basePath%>" name="content" isSimple="true" openUploaderByGallery="true">
						${entityInstance_Map.content}
					</commonUI:htmlEditor>
				</td>
			</tr>
			
			<jsp:invoke fragment="extraField2" />
			
			<%
			if(labels.get("intro") != null ){ %>
			<tr> 
				<td>${labels.intro}：</td>
				<td colspan="3">
					<textarea name="intro" style="width:100%;height:50px;">
						${entityInstance_Map.intro}
					</textarea>
				</td>
			</tr>
			<%} %>

		</table>
		<div class="btns">
			<button>保存</button>
			<button class="return">返回</button>
		</div>
 	</form>
 	    <commonUI:uploader isShowCover="false" insert2article_gallery="true" />
    	<commonUI:public load="form_upload_iframe" />
    	<commonUI:public load="loading" />
    	<commonUI:public load="lightbox" />
    </body>
</html>